﻿using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

namespace shenghua.Migrations
{
    public partial class addentity12 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "ShippingAddresses");

            migrationBuilder.DropColumn(
                name: "Amount",
                table: "MemberCoupons");

            migrationBuilder.AddColumn<bool>(
                name: "AllowFreeShipping",
                table: "ShippingTemplates",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<string>(
                name: "ExtensionData",
                table: "ShippingTemplates",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "Areas_StringValue",
                table: "ShippingTemplates",
                nullable: true);

            migrationBuilder.AddColumn<int>(
                name: "Amount_MoneyType",
                table: "MemberCoupons",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<double>(
                name: "Amount_Value",
                table: "MemberCoupons",
                nullable: false,
                defaultValue: 0.0);

            migrationBuilder.AddColumn<int>(
                name: "GrantedCount",
                table: "Coupons",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<int>(
                name: "TotalCount",
                table: "Coupons",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<int>(
                name: "UsedCount",
                table: "Coupons",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.CreateTable(
                name: "AdminShippingAddresses",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    PersonName = table.Column<string>(nullable: true),
                    PhoneNumber = table.Column<string>(nullable: true),
                    Province = table.Column<string>(nullable: true),
                    City = table.Column<string>(nullable: true),
                    County = table.Column<string>(nullable: true),
                    DetailedAddress = table.Column<string>(nullable: true),
                    IsDefault = table.Column<bool>(nullable: false),
                    AdminId = table.Column<long>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AdminShippingAddresses", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "GrantCouponLogs",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    MemberId = table.Column<long>(nullable: false),
                    MemberUserName = table.Column<string>(nullable: true),
                    CouponId = table.Column<int>(nullable: false),
                    CouponName = table.Column<string>(nullable: true),
                    CreationTime = table.Column<DateTime>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_GrantCouponLogs", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "MemberShippingAddresses",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    PersonName = table.Column<string>(nullable: true),
                    PhoneNumber = table.Column<string>(nullable: true),
                    Province = table.Column<string>(nullable: true),
                    City = table.Column<string>(nullable: true),
                    County = table.Column<string>(nullable: true),
                    DetailedAddress = table.Column<string>(nullable: true),
                    IsDefault = table.Column<bool>(nullable: false),
                    MemberId = table.Column<long>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MemberShippingAddresses", x => x.Id);
                });
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "AdminShippingAddresses");

            migrationBuilder.DropTable(
                name: "GrantCouponLogs");

            migrationBuilder.DropTable(
                name: "MemberShippingAddresses");

            migrationBuilder.DropColumn(
                name: "AllowFreeShipping",
                table: "ShippingTemplates");

            migrationBuilder.DropColumn(
                name: "ExtensionData",
                table: "ShippingTemplates");

            migrationBuilder.DropColumn(
                name: "Areas_StringValue",
                table: "ShippingTemplates");

            migrationBuilder.DropColumn(
                name: "Amount_MoneyType",
                table: "MemberCoupons");

            migrationBuilder.DropColumn(
                name: "Amount_Value",
                table: "MemberCoupons");

            migrationBuilder.DropColumn(
                name: "GrantedCount",
                table: "Coupons");

            migrationBuilder.DropColumn(
                name: "TotalCount",
                table: "Coupons");

            migrationBuilder.DropColumn(
                name: "UsedCount",
                table: "Coupons");

            migrationBuilder.AddColumn<float>(
                name: "Amount",
                table: "MemberCoupons",
                nullable: false,
                defaultValue: 0f);

            migrationBuilder.CreateTable(
                name: "ShippingAddresses",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    City = table.Column<string>(nullable: true),
                    County = table.Column<string>(nullable: true),
                    DetailedAddress = table.Column<string>(nullable: true),
                    Discriminator = table.Column<string>(nullable: false),
                    IsDefaultAddress = table.Column<bool>(nullable: false),
                    PersonName = table.Column<string>(nullable: true),
                    PhoneNumber = table.Column<string>(nullable: true),
                    Province = table.Column<string>(nullable: true),
                    UserId = table.Column<long>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ShippingAddresses", x => x.Id);
                });
        }
    }
}
